package com.generic.mybatis.dal.dao.criteria;

import com.generic.mybatis.dal.interceptor.automap.TableMapper;

import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * Right Like
 *
 * @author wuaj
 */
public class RLikeCriteria extends FieldCriteria {

    public RLikeCriteria(String field, Object value) {
        super(field, value);
    }

    @Override
    public void toSql(TableMapper mapper, SQL sql, Map paramMap) {
        String paramName = getParameterName(mapper);
        sql.WHERE(String.format("%s like #{%s}", getAlias(mapper), paramName));
        paramMap.put(paramName, value + "%");
    }
}
